from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import mail
import TwitterTool


class MainPage(webapp.RequestHandler):


    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('Hello, webapp World!')
        fromaddr = 'edcampion@googlemail.com'
        toaddrs = 'edcampion@gmail.com'
        msg = ""
        lstTweets = TwitterTool.CollectTweets("ictskills2013", 10)
        for tweet in lstTweets:
          msg += tweet + "\n"

        mail.send_mail(fromaddr, toaddrs, "Mick Tweets", msg)



application = webapp.WSGIApplication([('/', MainPage)], debug=True)


def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
